program madituan2;
const
fi='madituan2.inp';
fo='madituan2.out';
max=5;
ddd:array[1..8] of integer = (-1,-2,-2,-1,1,2,2,1);
ddc:array[1..8] of integer = (-2,-1,1,2,2,1,-1,-2);
var
	sd,sc:integer;
	a:array[1..max,1..max] of integer;
    f,g:text;
procedure nhap;
begin
	assign(f,fi);
	reset(f);
		read(f,sd,sc);
	close(f);
end;
function diduoc(d,c:integer):boolean;
begin
	diduoc:=false;
	if d<1 then exit;
	if d>max then exit;
	if c<1 then exit;
	if c>max then exit;
	if a[d,c]<>0 then exit;
	diduoc:=true;
end;

procedure xuat;
var	j,i:integer;
begin
	assign(g,fo);
	rewrite(g);
	for i:=1 to max do
    begin
		for j:=1 to max do
			write(g,a[i,j],'  ');
        writeln(g);
    end;
	close(g);
end;

function kiemtra(d,c:integer):boolean;
begin
	if (d=sd) and (c=sc) then
    	kiemtra:=true
    else
    	kiemtra:=false;
end;
procedure dequy(d,c,sobuoc:integer);
var	u,v,i:integer;
	kt:boolean;
begin
	if (sobuoc>25) and (kiemtra(d,c)=true) then
    begin
    	xuat;
		halt;
    end;
	for i:=1 to 8 do
	begin
		u:=d+ddd[i];
		v:=c+ddc[i];
		if diduoc(u,v)=true then
		begin
        	writeln(u,'      ',v);
			a[u,v]:=sobuoc;
			dequy(u,v,sobuoc+1);
			a[u,v]:=0;
		end;
	end;
end;


procedure xuly;
begin
	fillchar(a,sizeof(a),0);
	a[sd,sc]:=1;
	dequy(sd,sc,2);
end;
begin
	nhap;
	xuly;
end.
